package com.powerwyx.project.controller;

import com.powerwyx.project.annotation.AuthCheck;
import com.powerwyx.project.common.BaseResponse;
import com.powerwyx.project.common.ResultUtils;
import com.powerwyx.project.model.vo.InterfaceInfoVO;
import com.powerwyx.project.service.impl.StatsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 王艺锡
 * @version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/analysis")
public class StatsController {

    @Autowired
    private StatsService statsService;


    /**
     * 统计排名前三的接口总调用次数
     * @return
     */
    @GetMapping("/top/interface/invoke")
    @AuthCheck(mustRole = "admin")
    public BaseResponse<List<InterfaceInfoVO>> listTopInvokeInterfaceInfo(){
        List<InterfaceInfoVO>  interfaceInfoVOList = statsService.listTopInvokeInterfaceInfo();
        return ResultUtils.success(interfaceInfoVOList);
    }
}
